#pragma once

#include <netinet/in.h>
#include <netinet/ip.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <stdio.h>
#include <string>
#include <assert.h>
#include <memory.h>
#include "json/json.h"
#include "ClientDescriptor.h"
#include "request.hpp"

class ExampleClient : public ClientDescriptor
{
public:
	ExampleClient(int fd, in_addr client_addr, uint16_t client_port, uint32_t timeout) :
		ClientDescriptor(fd, client_addr, client_port, timeout),
		last_active_(time(0)),
		sizeIsRead(false),
		packetSize(0),
		bytes_read(0)
	{
        memset(buffer,0,1024);
        data_buffer.clear();
	}

	bool ReadReady();
	bool WriteReady();
	bool HeartBeat();
	void ClientClose();
	void ServerClose();

protected:
    threadpool<rawMessage> tp;
    bool sizeIsRead;
	time_t last_active_;
	char buffer[1024];
    int packetSize;
    std::string data_buffer;
    int bytes_read;
};

